//
// Created by sjjmw on 2/23/2022.
//

#ifndef LEETCODE__17_H
#define LEETCODE__17_H

//todo
// 假设有k个人质和k个绑匪围成一圈。人质的编号从1到k，绑匪的编号从k+1到2k。
// 从编号1开始，每次从其中选出第m个人(隔m-1选出一人)出列。
// 希望求出m的最小值，使得最先出列的k个人都是绑匪，即都是编号从k+1到2k的人。
#include "iostream"

double get_price(char a) {
    switch (a) {
        case 'a':
            return 1.5;
        case 'o':
            return 1.4;
        case 'b':
            return 1.48;
        case 'p':
            return 1.08;
    }
    return 0;
}

int get_index(char a) {
    switch (a) {
        case 'a':
            return 0;
        case 'o':
            return 1;
        case 'b':
            return 2;
        case 'p':
            return 3;
    }
    return 4;
}
void print_w_f(int w,double f){
    auto a=printf("%.2f",f);
    while(a<w){
        printf(" ");
        a++;
    }
}
int main() {
    int set_cnt;
//    std::cin>>set_cnt;
    bool first= true;
    while (scanf("%d", &set_cnt) != EOF) {
        double prices[5]={0};
        double weights[5]={0};
        if(!first){
            printf("\n\n");

        }
        first=false;
        while (set_cnt) {
            char name;
            double cnt;
            std::cin >> name >> cnt;
            int index= get_index(name);
            weights[index]+=cnt;
            prices[index]+=cnt* get_price(name);
            weights[4]+=cnt;
            prices[4]+=cnt* get_price(name);
            set_cnt--;
        }
        printf("       apple  orange banana pineapple sum\n");
        printf("price  ");
        print_w_f(7,prices[0]);
        print_w_f(7,prices[1]);
        print_w_f(7,prices[2]);
        print_w_f(10,prices[3]);
        print_w_f(7,prices[4]);
        printf("\n");
        printf("weight ");
        print_w_f(7,weights[0]);
        print_w_f(7,weights[1]);
        print_w_f(7,weights[2]);
        print_w_f(10,weights[3]);
        print_w_f(7,weights[4]);
        printf("\n");
    }
    return 0;
}


#endif //LEETCODE__17_H
